package com.zfl.thread.day05;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class CompletableFutureDemo02 {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(3);
        CompletableFuture<Integer> completableFuture = CompletableFuture.supplyAsync(() -> {

            System.out.println("正在进行第一个阶段"); return 1;
        }, executorService).thenApply(v -> {
            System.out.println("正在进行第二个阶段");
            return v +2;
        }).thenApply(v->{
            System.out.println("正在进行第三个阶段");
            return v+3;
        });
//        System.out.println("join:_"+completableFuture.join());
        executorService.shutdown();
    }
}
